package top.kaoshanji.p2ch15a;

/**
 * 代码清单-p2ch15a-437页a：内存可见性示例
 * author kaoshanji
 * ^_^
 * create time 2025/2/23 16:02
 */
public class VisibilityDemo {

    private static boolean shutdown = false;

    static class HelloThread extends Thread {

        @Override
        public void run() {
            while (!shutdown) {
                //
            }
            System.out.println("exit hello");
        }
    }

    public static void main(String[] args) throws InterruptedException {
        new HelloThread().start();
        Thread.sleep(1000);
        shutdown = true;
        System.out.println("exit main");
    }


}
